﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DebugTools
{
    class DCS_Chroma:DCSource
    {
        public List<string> _ListTypes;

        public DCS_Chroma(string szInsID):base(szInsID)
        {
            _szErrCmd = "SYST:ERR?\n";
            _szErrRet = "0,No Error\r\n";
            _ListTypes = new List<string>();
        }

        public override bool Init()
        {
            bool bRet = false;
            _ListTypes.Add("CHROMA,62024P-80-60");      //CHROMA,62024P-80-60,03.20,01677
            _ListTypes.Add("CHROMA ATE,62100H-450");    //CHROMA ATE,62100H-450,00278,02.30

            for (int i = 0; i < _ListTypes.Count; i++)
            {
                bRet = this.QueryType().Contains(_ListTypes[i]);
                if (bRet)
                {
                    _szType = _ListTypes[i];
                    break;
                }
            }

            return base.Init();
        }

        public override void Set_VC(string Volt, string Current)
        {
            _szCmd = "SOUR:VOLT " + Volt + ";CURR " + Current + "\n";
            this.Write(_szCmd);
            if (Volt.Equals("0") || Current.Equals("0"))
                this.ONorOFF(false);
            else
                this.ONorOFF(true);
        }

        public override double Meas_Volt()
        {
            _szCmd = "MEAS:VOLT?\n";
            return base.Meas_Volt();
        }

        public override double Meas_Curr()
        {
            _szCmd = "MEAS:CURR?\n";
            return base.Meas_Curr();
        }

        public override double Meas_Power()
        {
            _szCmd = "MEAS:POW?\n";
            return base.Meas_Power();
        }

        public override void ONorOFF(bool NF)
        {
            _szCmd = NF ? "OUTP ON\n" : "OUTP OFF\n";
            this.Write(_szCmd);
        }

        public override bool QueryState()
        {
            return base.QueryState();
        }
    }
}
